import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import 'package:get/get.dart';

import '../../../../theme/app_colors.dart';
import '../../../../theme/app_text_theme.dart';
import 'msg_controller.dart';

class MsgView extends GetView<MsgController> {
  const MsgView({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Color_bg,
      body: Stack(
        children: [
          getTopBg(context),
          Column(
            children: [
              Container(
                margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
                height: AppBar().preferredSize.height,
                child: Stack(
                    children: [
                      Center(child: Text('消息', style: text_title_white)),
                      Positioned(
                        right: 15.w,
                        top: 0,
                        bottom: 0,
                        child: Row(children: [
                          Image.asset("assets/images/ic_clean.png", width: 20.w, height: 20.w),
                          SizedBox(width: 10.w),
                          InkWell(
                              onTap: () => controller.toBackFeed(),
                              child: Image.asset("assets/images/ic_msg.png", width: 20.w, height: 20.w)),
                        ]),
                      )
                    ]
                ),
              ),
              SizedBox(height: 10.w),
              Container(
                  margin: EdgeInsets.symmetric(horizontal: 15.w),
                  child: InkWell(
                      onTap: ()=> controller.apply(),
                      child: Image.asset("assets/images/ic_banner.png", width: context.width-30.w, height: (context.width-30.w) * 256 / 700))),
              // RefreshIndicator(
              //   onRefresh: () => controller.getProduct(),
              //   child: SizedBox(
              //     height: context.height - 54.w - MediaQuery.of(context).padding.top - AppBar().preferredSize.height,
              //     child: controller.obx((data) => setItem(data!),
              //       onLoading: Center(child: CupertinoActivityIndicator(radius: 15.w)),
              //       onEmpty: Center(child: Text('暂无产品',style: text_grey_16b.copyWith(fontSize: 24.sp))), //空数据显示
              //       onError: (error) => Center(child: Text('$error',style: text_grey_16b.copyWith(fontSize: 24.sp))), //出错界面显示
              //     ),
              //   ),
              // )
            ],
          )
        ],
      ),
    );
  }

  Widget getTopBg(BuildContext context){
    return Container(
      width: context.width,
      height: context.width / 2,
      decoration: const BoxDecoration(
        gradient: LinearGradient(
          begin: Alignment.topCenter,
          end: Alignment.bottomCenter,
          colors: [
            Color_main,
            Color(0xfff2f6ff)
          ],
        ),
      ),
    );
  }

}